import time
import threading

total =4
def create_item1():
    global total
    for i in range(10):
        time.sleep(1)
        total += 1
        print(total)
        print ('Create item 1 add')
    print('Create Item1 done')

def create_item2():
    global total
    for i in range(5):
        time.sleep(2)
        total += 1
        print(total)
        print ('Create item 2 add')
    print('Create Item2 done')

def limits():
    global total
    while 1:
        if total > 5:
            total -= 3
            print(total)
            print ('minus 3')
        else:
            time.sleep(1)
            print(total)
            print ('wait')


t1=threading.Thread(target=create_item1)
t2=threading.Thread(target=create_item2)
t3=threading.Thread(target=limits,daemon=True)

t1.start()
t2.start()
t3.start()

t1.join()
t2.join()

print ('finish')
